﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;

using DbSharp.Framework.CaseFile.Parser;
using DbSharp.Framework.CaseFile;

namespace UnitTestProject.CaseFile
{
    [TestFixture]
    public class DataTestCaseExtractorTest
    {

        [Test] 
        public void ExtractTestCases()
        {
            string testCaseFile = @"CaseFileSample\TestCase_V2_DataTest_1Test.xml";
            testCaseFile = @"CaseFileSample\Copy of TestCase_V2_DataTest_1Test.xml";
            CaseFileNavigator fileNavigator = new CaseFileNavigator(testCaseFile);

            DbConnectionConfigExtractor dbConnExtractor = new DbConnectionConfigExtractor(testCaseFile, fileNavigator.SelectGlobalSetting());
            CaseFileParser parser = new CaseFileParser(null, testCaseFile);

            UnitTestCaseExtractor caseExtractor = new UnitTestCaseExtractor(parser.ListStatement, fileNavigator.SelectGlobalSetting(), fileNavigator.SelectDataTestCasesRoot());  
            
            Assert.AreEqual(1, caseExtractor.ListCase.Count);
            
            string actualProcAlias = caseExtractor["dataTest1"].ReferResultsetSection.StatementDeclaration.Alias;
            Assert.AreEqual("procAlias2", actualProcAlias);

            long maxRecordCnt_Expected = 1000;
            long maxRecordCnt_Actual = caseExtractor.ListCase[0].TargetResultsetSection.OutputSetting.ExportRecordCount;
            Assert.GreaterOrEqual(maxRecordCnt_Actual,maxRecordCnt_Expected); 
        }
    }
}
